<template>
  <el-form :inline="true" :model="formInline" class="form-inline">
    <el-row class="row">
      <el-col :span="6">
        <el-form-item label="所属管廊：">
          <el-select v-model="formInline.pipeName" placeholder="--请选择--">
            <el-option
              v-for="item in pipeArray"
              :key="item.id"
              :label="item.pipeName"
              :value="item.pipeName"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="仓室位置：">
          <el-select
            v-model="formInline.storehouseName"
            placeholder="--请选择--"
          >
            <el-option
              v-for="item in warehouseArray"
              :key="item.id"
              :label="item.name"
              :value="item.name"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="防火区位置：">
          <el-select
            v-model="formInline.subregionName"
            placeholder="--请选择--"
          >
            <el-option
              v-for="item in fireproofArray"
              :key="item.id"
              :label="item.name"
              :value="item.name"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="3">
        <el-form-item class="btns">
          <el-button type="primary" @click="onSubmit">查询</el-button>
          <el-button type="success" @click="onClear">清空</el-button>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="维护类型：">
          <el-select v-model="formInline.maintainType" placeholder="--请选择--">
            <el-option
              v-for="item in repairTypeArray"
              :key="item.code"
              :label="item.value"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-col>

      <el-form-item label="维护人员：" class="inputDeep">
        <el-select
          v-model="formInline.maintainPersonnelName"
          placeholder="--请选择--"
        >
          <el-option
            v-for="item in PersonnelArray"
            :key="item.code"
            :label="item.name"
            :value="item.name"
          />
        </el-select>
      </el-form-item>
    </el-row>
  </el-form>
</template>

<script setup>
import { reactive, defineEmits, ref } from 'vue'
import { pipelist, warehouselist, fireprooflist } from '@/api/back'
import { repairType, searchPersonl } from '@/api/maintain'
const formInline = reactive({
  pipeName: '',
  storehouseName: '',
  subregionName: '',
  maintainType: '',
  maintainPersonnelName: ''
})
const pipeArray = ref([])
const warehouseArray = ref([])
const fireproofArray = ref([])
const repairTypeArray = ref([])
const PersonnelArray = ref([])
const getListData = async () => {
  pipeArray.value = await pipelist()
  warehouseArray.value = await warehouselist()
  fireproofArray.value = await fireprooflist()
  PersonnelArray.value = await searchPersonl()
  repairTypeArray.value = await repairType({
    code: '',
    type: 6
  })
}
getListData()

const emits = defineEmits(['onSearch'])
const onSubmit = () => {
  emits('onSearch', formInline)
}
const onClear = () => {
  formInline.pipeName = ''
  formInline.storehouseName = ''
  formInline.subregionName = ''
  formInline.maintainType = ''
  formInline.maintainPersonnelName = ''
  emits('onSearch', formInline)
}
</script>

<style lang="scss" scoped>
.form-line {
  width: 100%;
  position: relative;
  display: flex;
  column-gap: 20px;
  padding-bottom: 15px;
  // margin-top: -5px;
  .row {
    position: relative;
    width: 100%;
  }
}
.btns {
  position: absolute;
  right: 0;
  top: 4px;
}
:deep(.el-form-item) {
  margin-right: 20px !important;
}
:deep(.el-input__inner) {
  width: 247px;
  // border-radius: 2px 2px 2px 2px;
  opacity: 1;
  // border: 1px solid #ababab;
}
</style>
